if __name__ == '__main__':
    pass
import subprocess
import datetime
import time

def open_ex(dir_path):
    subprocess.Popen('explorer '+ dir_path.replace('/', '\\'))   
    return

basedir = 'D:/Raw Media/'

basedir ='D:\#External\Raw Media\Return of the Dell'
#basedir =  'D:/#External/Raw Media'

basedir = basedir.replace('/', '\\') 

open_ex(basedir)

import os
dir_list = []
for root, dirs,files in os.walk(basedir):
    dir_list.append(root)

filelist= []
d = ''
for d in dir_list:
    dir_file_list = os.listdir(d)
    if d.find('\\') != -1:
        if d[d.rfind('\\')+4:d.rfind('\\')+5] == '_':
            #open the folders
            open_ex(d)
        #if d.replace('\\', '/') == "D:/Raw Media/Mumbai/int/100_0206": 
        #    open_ex(d)
        #    print d[2:10]
        #    print d[d.rfind('\\')+4:d.rfind('\\')+5]
        print d
    #print d + ' directory has' + str(len(dir_file_list))
    
    for i in dir_file_list:
        tmpstr = d + '/' + i 
        if os.path.isfile(tmpstr):
            filelist.append(tmpstr)

print "list of files is " 
print len(filelist)

#time.ctime(os.path.getctime(j)) 

f = open(basedir.replace('/', '\\') + 'overview.txt','w')
for j in filelist:
    b= os.path.getsize(j)
    t= os.path.getmtime(j)
    f.write(j + ',' + str(b) + ',' + time.ctime(os.path.getctime(j)) + '\n')